<?php

if (is_numeric($_POST['parent_id'])) {
	$db->insert('blog_posts', array('category_id' => $_POST['parent_id'], 'site_id' => $site['id']));
	$post_id = $db->lastInsertId();
	$db->insert('blog_posts_revisions', array('post_id' => $post_id, 'title' => 'Untitled post', 'author_id' => $_SESSION['login']['user']['id'], 'user_id' => $_SESSION['login']['user']['id']));
	header('Content-type: application/json');
	echo json_encode(array('id' => $post_id));
}
